function queue(num) {
  let promise = Promise.resolve();
  num.map((v) => {
    //每次的then方法都返回一个new promise，赋值给同名变量promise
    promise = promise.then(() => {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          console.log(v);
          resolve();
        }, 1000);
      });
    });
  });
}
queue([1, 2, 3, 4, 5]);
